<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			<h2>当前的n是{{n}}</h2>
			<button @click="add">点我n+1</button>
			<button @click="bye">点我销毁vm</button>
		</div>
		<script type="text/javascript">
			const vm = new Vue({
				el: '#root',
				data: {
					n: 1
				},
				methods: {
					add() {
						this.n++
					},
					bye(){
						this.$destroy()
					}
				},
				watch:{
					n(){
						console.log('n变了');
					}
				},
				beforeCreate() {
					console.log('beforeCreate')

				},
				created() {
					console.log('created');
				},
				beforeMount() {
					console.log('beforeMount');
				},
				mounted() {
					console.log('mounted');
				},
				beforeUpdate() {
					console.log('beforeUpdate');
				},
				updated() {
					console.log('update');
				},
				beforeDestroy() {
					console.log('beforeDestroy');
				},
				destroyed() {
					console.log('destroyed');
				}
			})
		</script>
	</body>
</html>
